package com.tycmc.signelectroniccontracts.tools.base;

import android.app.Activity;
import android.content.Intent;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;

import androidx.fragment.app.Fragment;


/**
 * Created by gy on 2017/6/6.
 */

public class FraBase extends Fragment {
    public FraBase() {
    }
    public void hideSoftInputView() {
        try {
            InputMethodManager manager = ((InputMethodManager) getActivity().getSystemService(Activity.INPUT_METHOD_SERVICE));
            if (getActivity().getWindow().getAttributes().softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN) {
                if (getActivity().getCurrentFocus() != null)
                    manager.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);

    }

    /**
     * 跳转添加动画
     * @param intent 跳转的事件
     * @param enterAnim 跳转的进入动画
     * @param exitAnim 跳转的退出动画
     */
    public void start(Intent intent, int enterAnim, int exitAnim) {
        startActivity(intent);
        getActivity().overridePendingTransition(enterAnim,exitAnim);
    }

    /**
     * 跳转默认动画
     * @param intent
     */
    public void start(Intent intent){
        startActivity(intent);
    }
}
